Skip to content

Fix priority check for LXRT#3879

Merged
andypugh merged 1 commit intoLinuxCNC:2.9from
hdiethelm:fix_lxrt_prio_check
Mar 29, 2026
Merged

Fix priority check for LXRT#3879
andypugh merged 1 commit intoLinuxCNC:2.9from
hdiethelm:fix_lxrt_prio_check

Conversation

@hdiethelm
Copy link
Copy Markdown
Contributor

Based on this comment #3878 (comment), I track down the issue and fixed it.

It was introduced here:
233f381

git tag --contains 233f381
v2.10.0-pre0
v2.9.0
v2.9.0-pre1
v2.9.1
v2.9.2
v2.9.3
v2.9.4
v2.9.5
v2.9.6
v2.9.7
v2.9.8

That's why 2.9.0-pre0 in the picture was probably still working, however, I dont't have such an old VM to test this theory.

The issue is this check:

if ((prio > rtapi_prio_highest()) || (prio < rtapi_prio_lowest()))

It fails when the lowest prio is bigger than the highest:
#define RT_SCHED_HIGHEST_PRIORITY 0
#define RT_SCHED_LOWEST_PRIORITY 0x3fffFfff
The above commit introduced a fix returning the correct prio for LXRT and broke the check with that.

Tested with:
POSIX non-realtime
POSIX realtime
XENOMAI (posix-skin) realtime
LXRT realtime

Just tell me if branch 2.9 is wrong for this fix and I will rebase to master.

@andypugh
Copy link
Copy Markdown
Collaborator

I tried to build this PR with:

./configure --with-realtime=uspace --enable-build-documentation=none

On the 5.4.279-rtai kernel with Debian Trixie

I get the following error, any thoughts:


Linking rtapi_app
Compiling rtapi/uspace_rtai.cc
In file included from rtapi/uspace_rtai.cc:10:
/usr/include/x86_64-linux-gnu/sys/io.h:38:12: error: declaration of ‘int iopl(int) noexcept’ has a different exception specifier
   38 | extern int iopl (int __level) __THROW;
      |            ^~~~
In file included from /usr/include/rtai/rtai_lxrt.h:524,
                 from rtapi/uspace_rtai.cc:6:
/usr/include/rtai/asm/rtai_lxrt.h:170:38: note: from previous declaration ‘int iopl(int)’
  170 | #define rtai_iopl()  do { extern int iopl(int); iopl(3); } while (0)
      |                                      ^~~~
/usr/include/rtai/rtai_lxrt.h:607:9: note: in expansion of macro ‘rtai_iopl’
  607 |         rtai_iopl();
      |         ^~~~~~~~~
make: *** [Makefile:287: objects/rtapi/uspace_rtai.o] Error 1
make: Leaving directory '/home/andypugh/linuxcnc-dev/src'

I suspect that this is a consequence of the long and complex history of this particular VM.

@hdiethelm
Copy link
Copy Markdown
Contributor Author

I should probably also create an issue for https://github.com/NTULINUX/RTAI
I think this is in a package from there. rtai-modules-5.4.279: /usr/include/rtai/asm-x86/rtai_lxrt.h

This change will fix it:

--- rtai_lxrt.h.orig	2026-03-23 21:21:53.462988753 +0100
+++ /usr/include/rtai/asm-x86/rtai_lxrt.h	2026-03-23 21:22:24.946592950 +0100
@@ -167,7 +167,7 @@
         return ret;
 }
 
-#define rtai_iopl()  do { extern int iopl(int); iopl(3); } while (0)
+#define rtai_iopl()  do { extern int iopl(int) __THROW; iopl(3); } while (0)
 
 #endif /* __KERNEL__ */

I mentioned it already here but there are many things going on: #3873 (comment)

I think you will have the same issue on master and 2.9.

@andypugh
Copy link
Copy Markdown
Collaborator

andypugh@trixie:~/linuxcnc-dev/src$ halrun
halcmd: exit
Note: Using LXRT realtime

Works for me too, with the change.

I am not clear if it would work for everyone if I change my rtai includes before building a package.
I think it probably would. What do you think?

@andypugh andypugh merged commit 458b780 into LinuxCNC:2.9 Mar 29, 2026
17 checks passed
@hdiethelm
Copy link
Copy Markdown
Contributor Author

You build your packages based on https://github.com/NTULINUX/RTAI? I am on it here: NTULINUX/RTAI#20
It might well be that adding this __THROW breaks other stuff.

@andypugh
Copy link
Copy Markdown
Collaborator

You build your packages based on https://github.com/NTULINUX/RTAI?

No, I typically take the current 2.9 head and merge in https://github.com/LinuxCNC/linuxcnc/tree/andypugh/2.9-rtai to enable RTAI package building.
It's kludgy and clunky but I am not familiar enough with the package build system to properly and compatibly revert 6f28560

@hdiethelm
Copy link
Copy Markdown
Contributor Author

hdiethelm commented Mar 31, 2026

Ah sorry, i ment the package for rtai-modules-5.4.279 containing /usr/include/rtai/asm-x86/rtai_lxrt.h, the file I had to modify. I got this debian package from the linuxcnc package repo.
It probably would make more sense to fix this package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants